package com.solotiger.geographic.ui.view;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.solotiger.geographic.R;
import com.solotiger.geographic.biz.model.Album;
import com.solotiger.geographic.biz.model.Picture;

public class CollectHolderView extends FrameLayout {

    private Context mContext;

    private SimpleDraweeView mIvImage;

    private TextView mTvTitle;

    private ImageView mIvCollect;

    /**
     * 构造方法
     *
     * @param context
     */
    public CollectHolderView(Context context) {
        super(context);
        mContext = context;
        LayoutInflater.from(mContext).inflate(R.layout.item_collect_view, this, true);
    }

    /**
     * 设置数据
     *
     * @param picture
     */
    public void setData(Picture picture, OnClickListener onClickListener) {
        if (mIvImage == null) {
            mIvImage = (SimpleDraweeView) findViewById(R.id.image);
            mTvTitle = findViewById(R.id.title);
            mIvCollect = findViewById(R.id.iv_collect);
        }
        mTvTitle.setText(picture.getTitle());
        Uri uri = Uri.parse(picture.getUrl());
        mIvImage.setImageURI(uri);
        if (mIvCollect != null) {
            mIvCollect.setOnClickListener(onClickListener);
        }
    }

}
